//
//  ViewController.swift
//  CustomInputView
//
//  Created by 虞明义 on 2017/11/29.
//  Copyright © 2017年 yumingyi. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        
        tet.layer.borderColor = UIColor.gray.cgColor
        tet.layer.borderWidth = 1
        tet.delegate = self
        tet.dataSource = self
        tet.frame = CGRect.init(x: 100, y: 100, width: 100, height: 50)
        tet.text = "自定义样式"
        view.addSubview(tet)
        
        loadData()
    }
    
    
    let tet = YMYOneSelectField.init()
    func loadData(){
        DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 15) {
            self.datas = ["1","2","3","4","5","6","7","8"]
            self.tet.reloadData()
        }
    }
    
    fileprivate lazy var datas:[String] = []
    
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        view.endEditing(true)
    }
    
}



extension ViewController:YMYOneSelectFieldDelegate,YMYOneSelectFieldDataSource{
    func selectField(field: YMYOneSelectField) -> Int {
        return datas.count
    }
    
    func selectField(field: YMYOneSelectField, indexInDatas: Int) -> String? {
        return datas[indexInDatas]
    }
    
}

